package com.bgs.controller;

import com.bgs.pojo.*;
import com.bgs.service.FinanceService;
import com.bgs.service.UserService;
import com.bgs.tool.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: xkgc
 * @description:
 * @author: Mr.Zhao
 * @create: 2022-05-17 09:48
 */

@RestController
@RequestMapping("/zsl")
public class FinanceController {

    @Autowired
    private FinanceService financeService;

    //findAllFinance


    @GetMapping("/findAllFinance")
    public R findAllFinance(@RequestParam(defaultValue = "") String number, @RequestParam(defaultValue = "") Integer orderType){

        List<Finance> list= financeService.findAllFinance(number,orderType);


        return  R.ok().data("records",list);
    }

    @GetMapping("/findAllMoney/{storeId}")
    private R findAllMoney(@PathVariable Integer storeId){

        Finance list= financeService.findAllMoney(storeId);


        return  R.ok().data("monty",list);



    }
    @PostMapping("/addMoney")
    public R addMoney(@RequestBody FinWrite finWrite){

                int a= financeService.addMoney(finWrite);


                if (a>0){
                    return  R.ok().message("支付成功");
                }else {
                    return  R.error().message("支付失败");
                }


}

    @PostMapping("/zhiFuMoney")
    public R zhiFuMoney(@RequestBody FinWrite finWrite){

        int a= financeService.zhiFuMoney(finWrite);



            return  R.error().message("支付失败");

    }



    @PostMapping("/caiWuUp")
    public R caiWuUp(@RequestBody FinWrite finWrite) {

          int a= financeService.caiWuUp(finWrite);


           if (a>0){
        return R.ok().message("支付成功");
            }else {
                return  R.error().message("支付失败");
           }

    }

}
